﻿using System.Collections.Generic;
using JetBrains.Annotations;

namespace MugenMvvmToolkit.Interfaces
{
    /// <summary>
    ///     Represent the factory for create <see cref="IValidator" />.
    /// </summary>
    public interface IValidatorProvider
    {
        /// <summary>
        ///     Registers the specified validator use type.
        /// </summary>
        /// <typeparam name="TValidator">The type of validator.</typeparam>
        void Register<TValidator>() where TValidator : IValidator;

        /// <summary>
        ///     Registers the specified validator.
        /// </summary>
        /// <param name="validator">The specified validator</param>
        void Register([NotNull]IValidator validator);

        /// <summary>
        ///     Unregisters the specified validator use type.
        /// </summary>
        /// <typeparam name="TValidator">The type of validator.</typeparam>
        bool Unregister<TValidator>() where TValidator : IValidator;

        /// <summary>
        ///     Determines whether the specified validator is registered
        /// </summary>
        /// <typeparam name="TValidator">The type of validator.</typeparam>
        [Pure]
        bool IsRegister<TValidator>();

        /// <summary>
        ///     Gets the series of validators for the specified instance.
        /// </summary>
        /// <param name="instanceToValidate">The specified instance to validate.</param>
        /// <returns>A series instances of validators.</returns>
        [NotNull]
        IList<IValidator> GetValidators([NotNull]object instanceToValidate);

        /// <summary>
        ///     Gets the series of validators for the specified instance.
        /// </summary>
        /// <param name="context">The specified IValidatorContext.</param>
        /// <returns>A series instances of validators.</returns>
        [NotNull]
        IList<IValidator> GetValidators([NotNull]IValidatorContext context);

        /// <summary>
        ///     Creates a new validator-factory that is a copy of the current instance.
        /// </summary>
        /// <returns>
        ///     A new validator-factory that is a copy of this instance.
        /// </returns>
        IValidatorProvider Clone();
    }
}